# Maintainer: Pierre Schmitz <pierre@archlinux.de>
# Contributor: Alexandre Bique <bique.alexandre@gmail.com>

pkgname=hefur
pkgver=1.0
pkgrel=4
pkgdesc='A standalone and lightweight BitTorrent tracker'
arch=('x86_64')
url='https://github.com/abique/hefur'
license=('MIT')
makedepends=('git' 'cmake')
depends=('gnutls' 'xz' 'protobuf')
source=("git+https://github.com/abique/${pkgname}.git#tag=${pkgver}"
        'hefurd.service' 'tmpfiles.conf' 'sysusers.conf')
sha1sums=('SKIP'
          'd9359b0e1c54ef2d286c6161eb742d442ba1b766'
          'f482ed1715d5a375c4a8d1906436b946c0b02157'
          '306db71b24ea5ca3429b6f482ab310fc7cfde63c')

prepare() {
	cd "${srcdir}/${pkgname}"
	git submodule init
	git submodule update
	sed -i "s/PROJECT_NUMBER.*/PROJECT_NUMBER=${pkgver}/g" Doxyfile
	sed -i "s/tracker-controller.hh//g" hefur/CMakeLists.txt
}

build() {
	cd "${srcdir}/${pkgname}"
	mkdir build
	cd build
	cmake -DCMAKE_INSTALL_PREFIX=/usr ..
	make
}

package() {
	cd "${srcdir}/${pkgname}/build"
	DESTDIR="${pkgdir}" make install
	install -D -m644 "${srcdir}/hefurd.service" "${pkgdir}/usr/lib/systemd/system/hefurd.service"
	install -D -m644 "${srcdir}/tmpfiles.conf" "${pkgdir}/usr/lib/tmpfiles.d/hefurd.conf"
	install -D -m644 "${srcdir}/sysusers.conf" "${pkgdir}/usr/lib/sysusers.d/hefurd.conf"
	install -D -m644 "${srcdir}/${pkgname}/LICENSE.md" "${pkgdir}/usr/share/licenses/hefur/LICENSE"
}
